/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "contrato", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contrato.findAll", query = "SELECT c FROM Contrato c"),
    @NamedQuery(name = "Contrato.findByIdcontrato", query = "SELECT c FROM Contrato c WHERE c.contratoPK.idcontrato = :idcontrato"),
    @NamedQuery(name = "Contrato.findByIdcargo", query = "SELECT c FROM Contrato c WHERE c.contratoPK.idcargo = :idcargo"),
    @NamedQuery(name = "Contrato.findByCiEmp", query = "SELECT c FROM Contrato c WHERE c.contratoPK.ciEmp = :ciEmp"),
    @NamedQuery(name = "Contrato.findByFechaInicio", query = "SELECT c FROM Contrato c WHERE c.fechaInicio = :fechaInicio"),
    @NamedQuery(name = "Contrato.findByFechaFin", query = "SELECT c FROM Contrato c WHERE c.fechaFin = :fechaFin"),
    @NamedQuery(name = "Contrato.findByHoraEntrada", query = "SELECT c FROM Contrato c WHERE c.horaEntrada = :horaEntrada"),
    @NamedQuery(name = "Contrato.findByHoraSalida", query = "SELECT c FROM Contrato c WHERE c.horaSalida = :horaSalida")})
public class Contrato implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ContratoPK contratoPK;
    @Column(name = "fecha_inicio")
    private Integer fechaInicio;
    @Column(name = "fecha_fin")
    private Integer fechaFin;
    @Column(name = "hora_entrada")
    private Integer horaEntrada;
    @Column(name = "hora_salida")
    private Integer horaSalida;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contrato")
    private Collection<PlanillaPagoDet> planillaPagoDetCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contrato")
    private Collection<Indemnizacion> indemnizacionCollection;
    @JoinColumn(name = "ci_emp", referencedColumnName = "ci_emp", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Empleado empleado;
    @JoinColumn(name = "idjustificacion", referencedColumnName = "idjustificacion", nullable = false)
    @ManyToOne(optional = false)
    private Justificacion idjustificacion;
    @JoinColumn(name = "idcargo", referencedColumnName = "idcargo", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Cargo cargo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contrato")
    private Collection<Asistencia> asistenciaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contrato")
    private Collection<DescuentoPer> descuentoPerCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contrato")
    private Collection<Permisos> permisosCollection;

    public Contrato() {
    }

    public Contrato(ContratoPK contratoPK) {
        this.contratoPK = contratoPK;
    }

    public Contrato(int idcontrato, int idcargo, int ciEmp) {
        this.contratoPK = new ContratoPK(idcontrato, idcargo, ciEmp);
    }

    public ContratoPK getContratoPK() {
        return contratoPK;
    }

    public void setContratoPK(ContratoPK contratoPK) {
        this.contratoPK = contratoPK;
    }

    public Integer getFechaInicio() {
        return fechaInicio;
    }

    public void setFechaInicio(Integer fechaInicio) {
        this.fechaInicio = fechaInicio;
    }

    public Integer getFechaFin() {
        return fechaFin;
    }

    public void setFechaFin(Integer fechaFin) {
        this.fechaFin = fechaFin;
    }

    public Integer getHoraEntrada() {
        return horaEntrada;
    }

    public void setHoraEntrada(Integer horaEntrada) {
        this.horaEntrada = horaEntrada;
    }

    public Integer getHoraSalida() {
        return horaSalida;
    }

    public void setHoraSalida(Integer horaSalida) {
        this.horaSalida = horaSalida;
    }

    @XmlTransient
    public Collection<PlanillaPagoDet> getPlanillaPagoDetCollection() {
        return planillaPagoDetCollection;
    }

    public void setPlanillaPagoDetCollection(Collection<PlanillaPagoDet> planillaPagoDetCollection) {
        this.planillaPagoDetCollection = planillaPagoDetCollection;
    }

    @XmlTransient
    public Collection<Indemnizacion> getIndemnizacionCollection() {
        return indemnizacionCollection;
    }

    public void setIndemnizacionCollection(Collection<Indemnizacion> indemnizacionCollection) {
        this.indemnizacionCollection = indemnizacionCollection;
    }

    public Empleado getEmpleado() {
        return empleado;
    }

    public void setEmpleado(Empleado empleado) {
        this.empleado = empleado;
    }

    public Justificacion getIdjustificacion() {
        return idjustificacion;
    }

    public void setIdjustificacion(Justificacion idjustificacion) {
        this.idjustificacion = idjustificacion;
    }

    public Cargo getCargo() {
        return cargo;
    }

    public void setCargo(Cargo cargo) {
        this.cargo = cargo;
    }

    @XmlTransient
    public Collection<Asistencia> getAsistenciaCollection() {
        return asistenciaCollection;
    }

    public void setAsistenciaCollection(Collection<Asistencia> asistenciaCollection) {
        this.asistenciaCollection = asistenciaCollection;
    }

    @XmlTransient
    public Collection<DescuentoPer> getDescuentoPerCollection() {
        return descuentoPerCollection;
    }

    public void setDescuentoPerCollection(Collection<DescuentoPer> descuentoPerCollection) {
        this.descuentoPerCollection = descuentoPerCollection;
    }

    @XmlTransient
    public Collection<Permisos> getPermisosCollection() {
        return permisosCollection;
    }

    public void setPermisosCollection(Collection<Permisos> permisosCollection) {
        this.permisosCollection = permisosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (contratoPK != null ? contratoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contrato)) {
            return false;
        }
        Contrato other = (Contrato) object;
        if ((this.contratoPK == null && other.contratoPK != null) || (this.contratoPK != null && !this.contratoPK.equals(other.contratoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.Contrato[ contratoPK=" + contratoPK + " ]";
    }
    
}
